package main

import (
	"gq_volunteer_platform/bean"
	message_queue "gq_volunteer_platform/model/message_queue"
	"gq_volunteer_platform/model/weixin"
)

func ActionMessageQueue() error {

	var queueList []message_queue.MessageQueue
	// 查询 进行中 应当结束的 活动
	if err := bean.MysqlDb.
		Where("`result`=''").
		Limit(100).
		Order("`id` ASC").
		Find(&queueList).Error; err != nil {

		bean.Log.Error(err)
		return err
	}

	for _, item := range queueList {

		if err := weixin.MessageSend(item, []byte(item.Content)); err != nil {
			bean.Log.Error(err)
			return err
		}

		// if err := bean.MysqlDb.Delete(&item).Error; err != nil {
		// 	bean.Log.Error(err)
		// 	return err
		// }

	}

	return nil
}
